<%@page import="java.util.List"%>
<%@ page language="java" 
    import="com.jju.A1541.model.*"
     import="com.jju.A1541.dao.*"
    contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String bjzz = request.getParameter("bjzz");
        
        User user = UserDAO.login(username,password);
        if(bjzz==null){
        if(user !=null){//登陆成功
              //保存当前登陆者对象到session中
              request.getSession().setAttribute("login_user", user);
              request.getSession().setAttribute("u", username);
             //获得登陆跳转前的页面地址
             String fromURI =(String)session.getAttribute("fromURL");
             if(fromURI==null)  fromURI="index.jsp";
             response.sendRedirect(fromURI);
            }else{
               out.print("<script>alert('登陆失败'); window.location='login.jsp' </script>");
            }
        }else{
        	User user1 = UserDAO.login1(username, password);
        	if(user1 != null){//登陆成功
                //保存当前登陆者对象到session中
                request.getSession().setAttribute("login_user1", user1);
                request.getSession().setAttribute("u", username);
               //获得登陆跳转前的页面地址
               String fromURI =(String)session.getAttribute("fromURL");
               if(fromURI==null)  fromURI="index.jsp";
               response.sendRedirect(fromURI);
              }else{
                 out.print("<script>alert('登陆失败'); window.location='login.jsp' </script>");
              }
        		
        	}
        
%>